Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: resolve catastrophic backtracing issue with semver regex #7

Merged
merged 2 commits into from
Jul 24, 2024

Conversation

bgiori
Copy link
Collaborator

@bgiori bgiori commented Jul 24, 2024

No description provided.

@@ -39,7 +34,7 @@ internal data class SemanticVersion(
if (version == null) {
return null
}
val matchGroup = regex.matchEntire(version)?.groupValues ?: return null
val matchGroup = pattern.matchEntire(version)?.groupValues ?: return null
val major = matchGroup[1].toIntOrNull() ?: return null
val minor = matchGroup[2].toIntOrNull() ?: return null
val patch = matchGroup[4].toIntOrNull() ?: 0

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the matchGroup indices still correct? Does it start from 0? What do index 0 and 3 represent?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep!

Screenshot 2024-07-23 at 11 29 51 PM

0 is the full match
3 is everything after the 2nd .

Copy link

@sandeep-madugula sandeep-madugula left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have 1 comment. Otherwise LGTM.

@bgiori bgiori merged commit 6ae4209 into main Jul 24, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants